public class MyRunnable implements Runnable{
    private int ticket = 100;
    @Override
    public void run() {
        while(true){
            if(ticket <= 0){
                System.out.println("票已售罄！");
                break;
            }
            System.out.println(Thread.currentThread().getName() + "成功购票，剩余 "+(--ticket)+" 张~");
        }
    }
}
